package com.dujiu.leetcode.slidingWindow.fixed_lengthSlidingWindow;



public class P1052 {
    public int maxSatisfied(int[] customers, int[] grumpy, int minutes) {
        int n = customers.length;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (grumpy[i] == 0){
                // 不生气
                ans += customers[i];
                customers[i] = 0;
            }
        }
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            cur += customers[i];
            if (i >= minutes){
                cur -= customers[i-minutes];
                max = Math.max(max,cur);
            }
        }
        return ans + max;
    }


    public static void main(String[] args) {
        int[] customers = {1,0,1,2,1,1,7,5};
        int[] grumpy = {0,1,0,1,0,1,0,1};
        P1052 p = new P1052();
        System.out.println(p.maxSatisfied(customers, grumpy, 3));
    }
}
